Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port andor new ad format #724

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jwlodek
Copy link
Member

@jwlodek jwlodek commented Jan 8, 2025

Takes #679 and adds modifications to work with the changes to the new AD class structure. I don't have an Andor to test with, so would be good if we could test with the device.

@jwlodek jwlodek requested a review from DiamondJoseph January 8, 2025 17:47
@coretl coretl mentioned this pull request Jan 9, 2025
src/ophyd_async/epics/adandor/_andor_controller.py Outdated Show resolved Hide resolved
Comment on lines +38 to +49
def _get_trigger_mode(self, trigger: DetectorTrigger) -> Andor2TriggerMode:
supported_trigger_types = {
DetectorTrigger.INTERNAL: Andor2TriggerMode.INTERNAL,
DetectorTrigger.EDGE_TRIGGER: Andor2TriggerMode.EXT_TRIGGER,
}
if trigger not in supported_trigger_types:
raise ValueError(
f"{self.__class__.__name__} only supports the following trigger "
f"types: {supported_trigger_types} but was asked to "
f"use {trigger}"
)
return supported_trigger_types[trigger]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: If we can't make a new TriggerInfo for Andor, then it might nicer to replace this code with a from_detector_trigger(cls, trigger: DetectorTrigger) -> Andor2TriggerMode method on Andor2TriggerMode.

Comment on lines +23 to +25
def get_deadtime(self, exposure: float | None) -> float:
return _MIN_DEAD_TIME + (exposure or 0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i did a bad thing when I first made it, may be the better way to get the dead time is to use the accumulate period rather than exposure time, which we can read from this signal: BL99P-EA-DET-03:CAM:AndorAccumulatePeriod_RBV ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except this is a sync method so we can't read PVs here...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of interest, if I do want the deadtime to be from a readback channel, what is the best way to go about it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The answer is either:

  • We keep the ability to validate plans in advance, the we cannot touch hardware to calculate this number and have to duplicate the calculation of deadtime that's in the SDK into our code
  • We abandon the ability to validate plans in advance, then we can make this an async method and use the value of that PV after exposure time has been set

@callumforrester do we want to open this box?

@coretl
Copy link
Collaborator

coretl commented Jan 15, 2025

@Relm-Arrowny will you have a chance to try this on a real Andor please?

@Relm-Arrowny
Copy link
Contributor

@Relm-Arrowny will you have a chance to try this on a real Andor please?

sure, I will try this tomorrow or whenever it is free.

@Relm-Arrowny
Copy link
Contributor

Relm-Arrowny commented Jan 16, 2025

I fell over on the first step, I could not connect due to mismatch DataType
TypeError: BL99P-EA-DET-03:CAM:DataType_RBV has choices ('UInt16', 'UInt32', '', '', '', '', '', '', 'Float32', 'Float64'), but <enum 'ADBaseDataType'> requested ['Int8', 'UInt8', 'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64', 'Float32', 'Float64'] to be strictly equal to them.
We had this one before and see here
Andor 2 also has a different imageMode which causes this error:
TypeError: BL99P-EA-DET-03:CAM:ImageMode_RBV has choices ('Single', 'Multiple', 'Continuous', 'Fast Kinetics'), but <enum 'ImageMode'> requested ['Single', 'Multiple', 'Continuous'] to be strictly equal to them.

@jwlodek
Copy link
Member Author

jwlodek commented Jan 16, 2025

@Relm-Arrowny I've pushed another change that moves the superclass init before the overrides to image_mode and data_type, and I've made the data_type a SubsetEnum. Could you pull this change and see if it allows you to connect?

@Relm-Arrowny
Copy link
Contributor

Relm-Arrowny commented Jan 16, 2025

@Relm-Arrowny I've pushed another change that moves the superclass init before the overrides to image_mode and data_type, and I've made the data_type a SubsetEnum. Could you pull this change and see if it allows you to connect?

Connected and did a few scans with it, as far as I can tell it is working better than ever, thanks.

@@ -16,23 +16,30 @@ class Andor2TriggerMode(StrictEnum):
SOFTWARE = "Software"


class ImageMode(StrictEnum):
class Andor2ImageMode(StrictEnum):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this one subclass the ADBase one and add FAST_KINETICS to it?

self.trigger_mode = epics_signal_rw(Andor2TriggerMode, prefix + "TriggerMode")
self.data_type = epics_signal_r(ADBaseDataType, prefix + "DataType_RBV")
self.andor_accumulate_period = epics_signal_r(
float, prefix + "AndorAccumulatePeriod_RBV"
)
self.image_mode = epics_signal_rw_rbv(ImageMode, prefix + "ImageMode")
super().__init__(prefix, name=name)
self.image_mode = epics_signal_rw_rbv(Andor2ImageMode, prefix + "ImageMode")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a relatively common pattern, overriding the image mode to be a subset of what the baseclass provides. We have SubsetEnum already, should we have SupersetEnum too? Or we could drop to string in the baseclass...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants